﻿namespace RialternativeSample.ViewModels
{
    using System.ServiceModel.DomainServices.Client;
    using System.Windows.Input;
    using RialternativeSample.Client.Commanding;
    using RialternativeSample.Client.Infrastructure;
    using RialternativeSample.Server.NorthwindService;
    using RialternativeSample.ViewModels.Interfaces;

    public class CustomersViewModelOld : Notifier, ICustomersViewModel
    {
        private NorthwindContext context;

        public CustomersViewModelOld()
        {
            this.context = new NorthwindContext();
            this.DeleteCustomerCommand = new RelayCommand<Customers>(this.DeleteCustomer);
            this.context.Load(this.context.GetCustomersQuery());
        }

        public ICommand DeleteCustomerCommand { get; private set; }

        public EntitySet<Customers> Customers
        {
            get
            {
                return this.context.Customers;
            }
        }

        private void DeleteCustomer(Customers customer)
        {
            this.context.Customers.Remove(customer);
            this.context.SubmitChanges();
        }
    }
}
